#include "systems/res_manager.hpp"

#include <iostream>
#include <sstream>

using namespace std;

struct script_file_t {
  std::string m_script;

  static boost::shared_ptr<script_file_t> create(boost::shared_ptr<std::stringstream> &stream) {
    cout << "Creating resource from stream..." << endl;
    boost::shared_ptr<script_file_t> ret(new script_file_t);
    ret->m_script = stream->str();
    return ret;
  }

};


int main(int argc, char **argv) {

  try {
    setlocale( LC_ALL, "" );
    
    cout << "--------- creating res manager -------------" << endl;

    boost::shared_ptr<res_manager_t> res_mgr = res_manager_t::create();

    cout << "--------- adding resource locations -------------" << endl;

    res_mgr->add_res_location("common"); // zipped resources

    cout << "--------- loading our resources -------------" << endl;

    cout << "---script_file_t---" << endl;

    boost::shared_ptr<script_file_t> script = res_mgr->get_res<script_file_t>("scripts/start_up.lua");

    cout << "script: " << script->m_script << endl;
    
    cout << "---reread same resource script_file_t---" << endl;

    boost::shared_ptr<script_file_t> script_copy = res_mgr->get_res<script_file_t>("scripts/start_up.lua");

    cout << "---end test---" << endl;
  }
  catch(const exception& e){
    cout<<"Exception: "<< e.what() << endl;
  }

  cin.get();
  return 0;
}

